package me.shurufa.holder;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import butterknife.Bind;
import butterknife.ButterKnife;
import me.shurufa.R;
import me.shurufa.model.Comment;
import me.shurufa.widget.CircleImageView;

/**
 * 在图书信息里点击查看全部评价弹出的列表的ViewHolder
 *
 * @FileName: me.shurufa.holder.BookCommentViewHolder.java
 * @author: kHRYSTAL
 * @email: 723526676@qq.com
 * @date: 2016-02-02 15:32
 */
public class BookCommentViewHolder extends BaseViewHolder{

    @Bind(R.id.comment_avatar)
    CircleImageView commentAvatar;
    @Bind(R.id.comment_nick)
    TextView commentNick;
    @Bind(R.id.comment_comment)
    TextView commentComment;
    @Bind(R.id.comment_divider)
    View commentDivider;

    private Context mContext;
    private Comment mComment;

    public BookCommentViewHolder(View itemView, Object parent) {
        super(itemView, parent);
        mContext = itemView.getContext();
        ButterKnife.bind(this, itemView);
    }

    public void bind(Comment comment){
        if (comment==null)
            return;
        mComment = comment;
        if (comment.user_info!=null){
            if (!TextUtils.isEmpty(comment.user_info.avatar))
                Glide.with(mContext).load(comment.user_info.avatar).into(commentAvatar);
            else
                commentAvatar.setImageResource(R.drawable.default_avatar);
            if (!TextUtils.isEmpty(comment.user_info.nickname))
                commentNick.setText(comment.user_info.nickname);
            else
                commentNick.setText("");
        }
        if (!TextUtils.isEmpty(comment.content))
            commentComment.setText(comment.content);
        else
            commentComment.setText("");
    }


}
